<?php

/**
 * DomainForm for bind customize domain
 */
class DomainForm extends CFormModel
{
	public $domain; 

	/**
	 * Declares the validation rules.
	 * The rules state that username and password are required,
	 * and password needs to be authenticated.
	 */
	public function rules()
	{
		return array(
			// username and password are required
			array('domain', 'required'), 
			array('domain', 'length','max'=>20,'min'=>4,'message'=>'您的名字不能太长也不能太短哦[4-20]。^_^'), 
			array('domain', 'EMongoUniqueValidator', 'condition'=>array('email'=>array('notEq'=>Yii::app()->user->getId())),'message'=>'这个网址太抢手了，换一个吧！'),
			
		);
	}

	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels()
	{
		return array(
			'domain'=>'个性化域名',
		);
	}
//	public function domain(){
//	    $user = User::model()->find(array('email'=>Yii::app()->user->getId()));
//	    $user->domain = $this->domain;
//
//	    return $user->validate() && $user->save();
//	}
//	
	public function model ($className = __CLASS__)
    {
        return User::model();
    }
}
